// 文章管理模块
const express = require('express');
const router = express.Router();
const db = require('../../db/index');
// 文章分类展示页面
router.get('/classify', (req, res) => {
  res.render('admin/article_classification');
});
// 获取文章的数据
router.get('/classlist', (req, res) => {
  // res.render('admin/article.classification');
  var sql = `SELECT * FROM article_classification WHERE is_delete=0`;
  db.query(sql, (err, results) => {
    if (err) return res.send({ code: 1, msg: err.message });
    if (results.length != 0) {
      // 查询到了数据
      return res.send({ code: 0, msg: '查询成功', data: results });
    } else {
      return res.send({ code: 1, msg: '查询失败' });
    }
  });
});

// 文章管理展示页面
router.get('/', (req, res) => {
  res.render('admin/article_management');
});
// 获取文章数据
router.get('/list', (req, res) => {
  res.render('admin/article_management');
});
// 快讯管理
router.get('/flash', (req, res) => {
  res.render('admin/express_management');
});
module.exports = router;
